﻿using System;
using UnityEngine;

public static class Bezier
{
    public static Vector3 GetFirstDerivative(Vector3 p0, Vector3 p1, Vector3 p2, float t)
    {
        return (Vector3) (((2f * (1f - t)) * (p1 - p0)) + ((2f * t) * (p2 - p1)));
    }

    public static Vector3 GetFirstDerivative(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t)
    {
        t = Mathf.Clamp01(t);
        float num = 1f - t;
        return (Vector3) (((((3f * num) * num) * (p1 - p0)) + (((6f * num) * t) * (p2 - p1))) + (((3f * t) * t) * (p3 - p2)));
    }

    public static Vector3 GetPoint(Vector3 p0, Vector3 p1, Vector3 p2, float t)
    {
        t = Mathf.Clamp01(t);
        float num = 1f - t;
        return (Vector3) ((((num * num) * p0) + (((2f * num) * t) * p1)) + ((t * t) * p2));
    }

    public static Vector3 GetPoint(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t)
    {
        t = Mathf.Clamp01(t);
        float num = 1f - t;
        return (Vector3) ((((((num * num) * num) * p0) + ((((3f * num) * num) * t) * p1)) + ((((3f * num) * t) * t) * p2)) + (((t * t) * t) * p3));
    }
}

